﻿using sMES_Base.service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using sMES_Base;
using machine_checklist_get.Models;
using machine_checklist_get;

namespace machine_checklist_get_C
{
    /// <summary>
	/// 服務[machine_checklist_get]
    /// <auth>gracecai</auth><time>2018/11/26 下午 03:37:57</time>
    /// <description>機台點檢表取得</description>
    /// <list>
    ///     <modify>
    ///         <auth></auth><mantis></mantis><time></time>
    ///         <description>機台點檢表取得</description>
    ///     </modify>
    /// </list>
    /// </summary>
    public class machine_checklist_get_C : BaseService
    {
        public machine_checklist_get_C(ServiceInfo _ServiceInfo) : base(_ServiceInfo)
        {
        }

        public override ServiceResponse ExecuteImplement(ServiceRequest ServiceRequest, ServiceResponse ServiceResponse)
        {
            //將dynamic 物件轉換成實體物件
            REQ_machine_checklist_get content = ServiceRequest.GetContent<REQ_machine_checklist_get>();

            //取出Utilitiy
            machine_checklist_get_utility utility = GetUtilities<machine_checklist_get_utility>();
            //取得資料
            //20210609 Modify by德義家興for#91011: [标准][DEV][行业议题]机加工-CNC-批量设备点检
            if (content.selected_EquipmentList.Count >=2) //是否多選
            {
                ServiceResponse.Content = new RES_machine_checklist_get();
                ServiceResponse.Content = utility.GetMultiSelectedEquipmentCheckUprate(content);
            }else{
                ServiceResponse.Content = new RES_machine_checklist_get();
                ServiceResponse.Content.machine_checklist_get_detail = utility.GetMachineChecklist(content);
                ServiceResponse.Content.last_handle_time = utility.GetMachineLastHandTime (content);
            }

            return ServiceResponse;
        }
    }
}
